package ntd.util.frame.action.database.factory;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Opt;
import com.c.opt.enums.EnumQueryRuleType;
import com.c.opt.query.ComQueryInfo;
import com.modular.event.FactoryEventOpt;
import ntd.util.frame.auth.ToolLogin;
import ntd.util.frame.javacv.tool.ToolAiUserSites;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 查询特殊逻辑工厂函数
 */
public class FactoryTableBuild {

    public static List<ComQueryInfo> build(String tName) {
        List<ComQueryInfo> comQueryInfoList = new ArrayList<>();
        switch (tName) {
            case "account_content": {
//                return ListUtil.of(new ComQueryInfo("created_by", ToolLogin.getCurrUserId(), EnumQueryRuleType.RULE_EQ));
            }
            case "alarm_records": {
                Opt.ofEmptyAble(ToolAiUserSites.getCurrMns()).ifPresent(strings -> {
                   // 富铭mns 逻辑处理
                    comQueryInfoList.add(new ComQueryInfo("point_code", strings, EnumQueryRuleType.RULE_IN));
                });
                return comQueryInfoList;
            }
        }
        return comQueryInfoList;
    }

    public static void extHandle(String tName, Map<String, Object> map) {
        switch (tName) {
            case "alarm_records_opt": {
                Opt.ofBlankAble(map.get("alarmRecordsId")).ifPresent(o -> {
                    FactoryEventOpt.RECORDS.updateFinal(String.valueOf(o));
                });
                return;
            }
        }
    }

}
